namespace Data.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class removeColomumCreatedByFromWebsite : DbMigration
    {
        public override void Up()
        {
            DropForeignKey("dbo.Websites", "CreatedBy_Id", "dbo.Users");
            DropForeignKey("dbo.Categories", "CreatedBy_Id", "dbo.Users");

            DropForeignKey("dbo.Categories", "User_Id", "dbo.Users");
            DropIndex("dbo.Categories", new[] { "User_Id" });
            DropIndex("dbo.Categories", new[] { "CreatedBy_Id" });
            DropIndex("dbo.Websites", new[] { "CreatedBy_Id" });
            DropColumn("dbo.Categories", "CreatedBy_Id");
            RenameColumn(table: "dbo.Categories", name: "User_Id", newName: "CreatedBy_Id");
            AddForeignKey("dbo.Categories", "CreatedBy_Id", "dbo.Users", "Id", cascadeDelete: true);
            DropColumn("dbo.Websites", "CreatedBy_Id");
        }
        
        public override void Down()
        {
            AddColumn("dbo.Websites", "CreatedBy_Id", c => c.Guid());
            DropForeignKey("dbo.Categories", "CreatedBy_Id", "dbo.Users");
            RenameColumn(table: "dbo.Categories", name: "CreatedBy_Id", newName: "User_Id");
            AddColumn("dbo.Categories", "CreatedBy_Id", c => c.Guid());
            CreateIndex("dbo.Websites", "CreatedBy_Id");
            CreateIndex("dbo.Categories", "CreatedBy_Id");
            CreateIndex("dbo.Categories", "User_Id");
            AddForeignKey("dbo.Categories", "User_Id", "dbo.Users", "Id");
            AddForeignKey("dbo.Categories", "CreatedBy_Id", "dbo.Users", "Id");
            AddForeignKey("dbo.Websites", "CreatedBy_Id", "dbo.Users", "Id");
        }
    }
}
